﻿using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.Services;

namespace Kwd.Summary.Services
{
  public class ExplicitSummary : ISummaryStrategy
  {
    private IEnumerable<IHtmlFilter> _htmlFilters;

    public ExplicitSummary(IEnumerable<IHtmlFilter> htmlFilters)
    {
      _htmlFilters = htmlFilters;  
    }

    public HtmlString GenerateSummary(HtmlString defaultSummary, Models.SummaryPart summaryPart)
    {
      var filteredText = _htmlFilters.Aggregate(summaryPart.Text, (text, filter) => filter.ProcessContent(text, summaryPart.Format));

      return new HtmlString(filteredText);
    }
  }
}